﻿using Liang.DataBase.Model.Entity;
using Liang.UI;
using Liang.Resource;
using System;
using System.Data;
using System.Linq;
using WeifenLuo.WinFormsUI.Docking;

namespace Client
{
    public partial class FrmMainTool : DockContent
    {
        public FrmMainTool()
        {
            InitializeComponent();
            leftBar1.Initialize();
        }

        /// <summary>
        /// 设置子菜单
        /// </summary>
        /// <param name="module"></param>
        public void SetSubMenu(sys_module module)
        {
            foreach (sys_app appItem in module.apps)
            {
                // 查看用户是否拥有app的权限
                var result = MainFrm.AppSet.Where(q => q.appId.Equals(appItem.appId));
                if (0 < result.Count())
                {
                    leftBar1.AddBand(appItem.name, appItem.imgUrl, AssemblyHelper.GetImage("KeyerResource", appItem.imgUrl), new EventHandler(PanelEvent));
                }
            }
        }

        public void PanelEvent(object sender, EventArgs e)
        {
            LeftIcon ctrl = (LeftIcon)sender;
            MainFrm.GetMainForm().ShowContent(ctrl.Name);
        }
    }
}

